<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>心若在梦就在</title>
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <link rel="stylesheet" href="css/weui.css"/>
    <link rel="stylesheet" href="css/weuix.css"/>
    <style>
        body{
            margin: 10px 20px;
        }
    </style>
    <script src="js/zepto.min.js"></script>
    <script src="js/zepto.weui.js"></script>
    <script>
        var content = '/question';
        $(function(){
            var sss = function(){
                var t = $("#searchInput").val();
                if(t && t.length > 0){
                    $.getJSON(content + "/api/qQuestion/list",
                        {title: t} ,
                        function(res){
                            console.log(res);
                            if(res.data){
                                var data = res.data;
                                var show = $("#showRes");
                                show.html('');
                                show.append('<div class="weui-cells__title" >结果: '+data.length+'</div>');
                                for(var i=0;i<data.length;i++){
                                    show.append(' <div class="weui-cells">\n' +
                                        '        <div class="weui-cell">\n' +
                                        '            <div class="weui-cell__bd">\n' +
                                        '                <p>'+(i+1)+'. ['+ (data[i].type==1?'单选':data[i].type==2?'多选':'判断') + "]" + data[i].title +'</p>\n' +
                                        '            </div>\n' +
                                        '            <div class="weui-cell__ft">'+data[i].answer+'</div>\n' +
                                        '        </div>\n' +
                                        '    </div>');
                                }
                            }
                        })
                }
            };
            $("#search").click(sss);
            $("#searchInput").keypress(function (e) {console.log(e);
                if (e.which == 13) {sss();}
            });
        });

    </script>
</head>

<body ontouchstart>
<div class="page-hd">
    <p class="page-hd-desc"></p>
</div>

<div class="weui-search-bar" id="searchBar">
    <form class="weui-search-bar__form" action="#">
        <div class="weui-search-bar__box">
            <i class="weui-icon-search"></i>
            <input class="weui-search-bar__input " id="searchInput" placeholder="搜索" required="" type="search">
            <a href="javascript:" class="weui-icon-clear" id="searchClear"></a>
        </div>
        <label class="weui-search-bar__label" id="searchText" style="transform-origin: 0px 0px 0px; opacity: 1; transform: scale(1, 1);">
            <i class="weui-icon-search"></i>
            <span>搜索</span>
            <a href="javascript:" class="weui-search-bar__cancel-btn" id="searchCancel">X</a>
        </label>
    </form>
    <a href="javascript:" class="" id="search">搜索</a>
</div>
<br>


<div id="showRes" class="page-bd">
    <div class="weui-cells__title" >搜索结果</div>
    <div class="weui-cells">
        <div class="weui-cell">
            <div class="weui-cell__bd">
                <p></p>
            </div>
            <div class="weui-cell__ft"></div>
        </div>
    </div>
</div>

<br>
<div class="weui-footer weui-footer_fixed-bottom">
    <p class="weui-footer__links">
        <a href="../index.html" class="weui-footer__link">加题</a>
    </p>
    <p class="weui-footer__text">Copyright &copy</p>
</div>
</body>
</html>
